<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 周超
  Date: 2019/1/22
  Time: 10:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>商品分类表的分页查询</title>

</head>
<body>
<tr>
    <td><input id="name" name="name" type="text" value="${clname}" placeholder="请输入您要查询的商品分类"></td>
    <td><input type="button" value="查询" onclick="chaxun()"></td>
    <td><input type="button" value="新增" onclick="addGoodsClass()"/></td>
    <td><input type="button" value="查看商品" onclick="GoodsInfo()"/></td>
</tr>
<table>
    <tr>
        <td>商品分类id</td>
        <td>商品分类名称</td>
        <td>父级分类id</td>
        <td>分类描述</td>
        <td colspan="2">操作</td>
    </tr>

    <c:forEach var="cl" items="${pb.list}">
        <tr>
            <td>${cl.clId}</td>
            <td>${cl.clName}</td>
            <td>${cl.faId}</td>
            <td>${cl.clDescribe}</td>
            <td><input type="button" value="修改" onclick="modify(${cl.clId})"/></td>
            <td><input type="button" value="删除" onclick="deleteMessage(${cl.clId})"/></td>
        </tr>
    </c:forEach>


</table>
<input id="shouye" type="button" value="首页" onclick="shouye()">
<input id="shangye" type="button" value="上一页" onclick="shangye()">
<input id="text" type="text" value="${pb.pageIndex}|${pb.totalPage}" onclick="tiaozhuan()">
<input id="xiaye" type="button" value="下一页" onclick="xiaye()">
<input id="weiye" type="button" value="尾页" onclick="weiye()">
</body>
<script type="text/javascript">


    function GoodsInfo() {
        window.location.href="GoodsPageBeanListServlet";
    }

    function chaxun() {
        var clname=document.getElementById("name").value;
        window.location.href="GoodsClassPageBeanListServlet?pageIndex=1&clname="+clname;
    }
    function modify(clId) {
        var bo=confirm("您确定要修改这条商品分类信息吗");
        if(bo){
            window.location.href="GoodsClassModifyServlet?clId="+clId;

        }
        else{
            alert("已经取消修改");
        }
    }
    function deleteMessage(clId) {
        var bo=confirm("您确定要删除这条商品分类信息吗");
        if(bo){
            window.location.href="DeleteGoodsClassServlet?clId="+clId;
            alert("已删除该商品");
        }
        else{
            alert("已经取消删除");
        }
    }
    function addGoodsClass() {
        window.location.href="jsp/zc/AddGoodsClass.jsp";
        //response.sendRedirect("ListEmp2.jsp");
    }

    function shouye() {
        var clname=document.getElementById("name").value;
        window.location.href="GoodsClassPageBeanListServlet?pageIndex=1&clname="+clname;
    }
    function shangye() {
        var clname=document.getElementById("name").value;
        //应该获取当前页码
        var pageIndex="${pb.pageIndex}";
        if(1==pageIndex){
            alert("已经是第一页了");
        }else{
            pageIndex--;
            window.location.href="GoodsClassPageBeanListServlet?pageIndex="+pageIndex+"&clname="+clname;
        }
    }

    function tiaozhuan() {

    }

    function xiaye() {
        var clname=document.getElementById("name").value;
        //应该获取当前页码
        var pageIndex="${pb.pageIndex}";
        var pageTotal="${pb.totalPage}";
        if(pageIndex==pageTotal){
            alert("已经是最后一页了");
        }else{
            pageIndex++;
            window.location.href="GoodsClassPageBeanListServlet?pageIndex="+pageIndex+"&clname="+clname;

        }

    }
    function weiye() {
        var clname=document.getElementById("name").value;
        var pageTotal="${pb.totalPage}";
        window.location.href="GoodsClassPageBeanListServlet?pageIndex="+pageTotal+"&clname="+clname;
    }
</script>
</html>
